diff options
author | Ashelyn Rose <git@tempest.dev> | 2023-05-08 19:25:46 -0600 |
---|---|---|
committer | Ashelyn Rose <git@tempest.dev> | 2023-05-08 19:29:19 -0600 |
commit | d89d92d3936683f4212186cef517c7930dd5b33a (patch) | |
tree | cba24caddd1dc5f950b5e42eb333261f0c13dca5 /app/posts/[slug] | |
parent | 6cddfdf8fe9bccc291ee8625d42cb42fd4ce2134 (diff) |
add markdown rendering, copy in old posts
Diffstat (limited to 'app/posts/[slug]')
-rw-r--r-- | app/posts/[slug]/page.tsx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/app/posts/[slug]/page.tsx b/app/posts/[slug]/page.tsx new file mode 100644 index 0000000..2110a35 --- /dev/null +++ b/app/posts/[slug]/page.tsx @@ -0,0 +1,28 @@ +import { notFound } from 'next/navigation' +import Markdown from 'markdown-to-jsx' + +import InfoBar from '~/components/InfoBar' +import { getPostSlugs, loadSinglePage } from '~/utils/post' + +export async function generateStaticParams() { + const slugs = await getPostSlugs() + return slugs.map((slug: string) => ({ slug })) +} + +export default async function Post({ params: { slug } }) { + const post = await loadSinglePage(slug) + if (!post) notFound() + + return ( + <> + <h1 className="pageTitle"> + {post.title} + </h1> + <main className="mainColumn"> + <InfoBar authorName={post.author} publishedDate={post.date} /> + <Markdown>{post.body}</Markdown> + </main> + </> + ) +} + |